/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "ADMIN")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Admin.findAll", query = "SELECT a FROM Admin a"),
    @NamedQuery(name = "Admin.findByIdAdmin", query = "SELECT a FROM Admin a WHERE a.adminPK.idAdmin = :idAdmin"),
    @NamedQuery(name = "Admin.findByIdPersonalInfo", query = "SELECT a FROM Admin a WHERE a.adminPK.idPersonalInfo = :idPersonalInfo"),
    @NamedQuery(name = "Admin.findByIdBranchenterprise1", query = "SELECT a FROM Admin a WHERE a.adminPK.idBranchenterprise1 = :idBranchenterprise1"),
    @NamedQuery(name = "Admin.findByIdEnterprise1", query = "SELECT a FROM Admin a WHERE a.adminPK.idEnterprise1 = :idEnterprise1")})
public class Admin implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AdminPK adminPK;
    @JoinColumns({
        @JoinColumn(name = "ID_PERSONAL_INFO", referencedColumnName = "ID_PERSONAL_INFO", insertable = false, updatable = false),
        @JoinColumn(name = "ID_BRANCHENTERPRISE1", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE1", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)})
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private PersonalInfo personalInfo;

    public Admin() {
    }

    public Admin(AdminPK adminPK) {
        this.adminPK = adminPK;
    }

    public Admin(BigInteger idAdmin, BigInteger idPersonalInfo, BigInteger idBranchenterprise1, BigInteger idEnterprise1) {
        this.adminPK = new AdminPK(idAdmin, idPersonalInfo, idBranchenterprise1, idEnterprise1);
    }

    public AdminPK getAdminPK() {
        return adminPK;
    }

    public void setAdminPK(AdminPK adminPK) {
        this.adminPK = adminPK;
    }

    public PersonalInfo getPersonalInfo() {
        return personalInfo;
    }

    public void setPersonalInfo(PersonalInfo personalInfo) {
        this.personalInfo = personalInfo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (adminPK != null ? adminPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Admin)) {
            return false;
        }
        Admin other = (Admin) object;
        if ((this.adminPK == null && other.adminPK != null) || (this.adminPK != null && !this.adminPK.equals(other.adminPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Admin[ adminPK=" + adminPK + " ]";
    }
    
}
